AreaWindow = function(title){
	//定义一个load方法给让表单加载数据信息
	var loadInfo = function(rec){
		form.getForm().loadRecord(rec);
		
	}
	//获取表单信息并定义事件
	var submit = function(){
		if(form.getForm().isValid()){
			var data = form.getForm().getValues();
		    var win = form.ownerCt;
		    win.fireEvent('submit',win,form,data);
		}else{
			Ext.MessageBox.alert('系统提示','请填写合适的数据!');
		}
		
	}
	
	//建立form表单
	var form = new Ext.form.FormPanel(
		{
			frame:true,
			enableKeyEvents: true,
			defaults:{
				anchor:'90%',
				maxLength:50,
				maxLengthText:'最多不能超过50个字',
				listeners : {  
	                specialkey : function(field, e) {  
	                    if (e.getKey() == Ext.EventObject.ENTER) {  
	                        submit();
	                    }  
	                }  
	            }  
			},
			autoHeight: true,
			items:[
				{
					xtype:'textfield',
					name:'name',
					allowBlank:false,
					tabIndex:1,
					blankText:'小区名称为必填项',
					fieldLabel:'小区名称'
				},
				{
					xtype:'textfield',
					name:'areaid',
					tabIndex:2,
					fieldLabel:'小区编号'
				},
				{
					xtype		:'numberfield',
					name		:'usercounts',
					allowDecimals : false,
					minValue	:0, 
					minText 	:'最小值为0',
					invalidText :'只能输入整数',
					tabIndex	:3,
					fieldLabel	:'用户数量'
				},
				{
					xtype:'numberfield',
					name:'useareas',
					allowDecimals : true,
					decimalPrecision :2,
					decimalSeparator :'.',
					tabIndex:4,
					minValue	:0, 
					minText 	:'最小值为0',
					fieldLabel:'使用面积'
				},
				{
					xtype:'numberfield',
					name:'feesareas',
					allowDecimals : true,
					decimalPrecision :2,
					decimalSeparator :'.',
					tabIndex:5,
					minValue	:0, 
					minText 	:'最小值为0',
					fieldLabel:'缴费面积'
				},
				{
					xtype:'textfield',
					name:'address',
					allowBlank:false,
					blankText:'地址不能为空',
					tabIndex:6,
					fieldLabel:'地址'
				},
				{
					xtype:'textfield',
					name:'notes',
					tabIndex:7,
					fieldLabel:'备注'
				},{
					xtype:'hidden',
					name:'aid'
				}]
		}
	);
	
	//这里是Window的配置项
	var config = {
		load:loadInfo,
		buttons:[
			{
				text:'确定',
				iconCls:'confirm',
				handler:submit,
				scope:this
			},
			{
				text:'取消',
				iconCls:'cancel',
				handler:function(){this.close()},
				scope:this
			}],
		items:[form],
		layout:'fit',
		constrain : true, 
		constrainHeader : true, 
		modal:true,
		title:title,
		width:400,
		autoHeight:true 
	};
	AreaWindow.superclass.constructor.call(this,config);
}
Ext.extend(AreaWindow,Ext.Window);